package com.lee9213.demo.dao.impl;

import java.util.List;

import com.lee9213.demo.entity.DemoEntity;
import com.lee9213.demo.mapper.IDemoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lee9213.core.annotation.Transactional;
import com.lee9213.demo.dao.IUserDao;
import com.lee9213.demo.entity.UserEntity;
import com.lee9213.demo.mapper.IUserMapper;

/**
 * @author lee9213@163.com
 * @version 1.0
 * @date 2017-11-09 21:45
 */
@Transactional("jtaTransactionManager")
@Service
public class UserDaoImpl implements IUserDao {


    @Autowired
    protected IUserMapper mapper;
    @Autowired
    private IDemoMapper demoMapper;

    @Override
    public Long save(UserEntity entity) {

        return mapper.save(entity);
    }

    @Override
    public Integer update(UserEntity entity) {
        mapper.update(new UserEntity("外部"));
        demoMapper.save(new DemoEntity("内部"));
        demoMapper.list();
        return 1;
    }

    @Override
    public List<UserEntity> list() {
        return mapper.list();
    }
}
